//
//  DDBossMessageViewController.m
//  DingDongZP
//
//  Created by Jyh on 16/4/20.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDBossMessageViewController.h"
#import "DDNetWorkManager.h"
#import "DDAPIGenerate.h"
#import "SVProgressHUD.h"
#import "DDNotficationView.h"
#import "DDBossNotificationsViewController.h"

@interface DDBossMessageViewController ()


@end

@implementation DDBossMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    DDNotficationView *notificationView = [[DDNotficationView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 197)];
    self.conversationListTableView.tableHeaderView = notificationView;
    
    // 点击通知
    __weak typeof(self) weakSelfNotice = self;
    [notificationView.notificationView bk_whenTapped:^{
        DDBossNotificationsViewController *vc = [[DDBossNotificationsViewController alloc] init];
        vc.hidesBottomBarWhenPushed = YES;
        [weakSelfNotice.navigationController pushViewController:vc animated:true];
    }];
    
    //  点击小叮咚
    __weak typeof(self) weakSelf = self;
    [notificationView.littleDingDong bk_whenTapped:^{
        feedBackVC *feed = [[feedBackVC alloc] init];//swift
        feed.hidesBottomBarWhenPushed = true;
        [weakSelf.navigationController pushViewController:feed animated:true];
    }];
    //
    self.navigationController.navigationBar.translucent = false;
    self.navigationController.navigationBar.barTintColor = COLOR_NAVIGATIONBAR;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:16]}];
}
-(UIBarButtonItem *)customBackItemWithTarget:(id)target action:(SEL)action {
    
    UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"navBack.png"] style:UIBarButtonItemStyleDone target:self action:@selector(doBack)];
    
    return  btn;
    
}


-(void)doBack {
    
    [self.navigationController popViewControllerAnimated:YES];
}

/**
 *  加载通知
 */
- (void)loadNotifications
{
    NSString *url = [[DDAPIGenerate sharedInstance] API:@"employer_query_notification_count"];
    [[DDNetWorkManager shareManager] POST:url parameters:nil success:^(id responseObject) {
        NSDictionary *data = responseObject[@"data"];
        if (![data isKindOfClass:[NSDictionary class]]) {
            return;
        }
        NSInteger viewCount = [data[@"notification_jobviewed_count"] integerValue];
        NSInteger newFinderCount = [data[@"notification_newjobfinders_count"] integerValue];
        
        DDNotficationView *headView = (DDNotficationView *)self.conversationListTableView.tableHeaderView;
        [headView setJobViewCount:viewCount
                newJobFinderCount:newFinderCount];
        
    } failure:^(id responseObject, NSError *error) {
        NSString *err = responseObject[@"msg"];
        [SVProgressHUD showInfoWithStatus:err];
    }];
}

@end
